package ru.cannabis;

import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import ru.cannabis.services.AuthService;
import ru.cannabis.database.IAccountDao;
import ru.cannabis.database.hbm.AccountDao;
import ru.cannabis.services.PlayerService;

public class Launcher
{
    private static AuthService authService;
    private static PlayerService playerService;

    private static IAccountDao accountDao;

    private static MainHandler mainHandler;
	
	
	/**
	* Init
	*/
	
    public static void main(String[] args)
    {
		AbstractApplicationContext ctx = new ClassPathXmlApplicationContext("spring-config.xml", "spring-quartz.xml");
		ctx.registerShutdownHook();

        authService = ctx.getBean("authService", AuthService.class);
        playerService = ctx.getBean("playerService", PlayerService.class);

        accountDao = ctx.getBean("accountDao", AccountDao.class);

        mainHandler = ctx.getBean("handler", MainHandler.class);
	}

	public static MainHandler getMainHandler()
    {
		return mainHandler;
	}

    public static AuthService getAuthService()
    {
        return authService;
    }

    public static void setAuthService(AuthService authService)
    {
        Launcher.authService = authService;
    }

    public static PlayerService getPlayerService() {
        return playerService;
    }

    public static void setPlayerService(PlayerService playerService) {
        Launcher.playerService = playerService;
    }

    public static IAccountDao getPlayerDao()
    {
        return accountDao;
    }

    public static void setPlayerDao(IAccountDao accountDao)
    {
        Launcher.accountDao = accountDao;
    }
}
